package com.itcncp.ucenter.rpc.service.impl;

import com.itcncp.common.annotation.BaseService;
import com.itcncp.common.base.BaseServiceImpl;
import com.itcncp.ucenter.dao.mapper.ItcsStationInfoMapper;
import com.itcncp.ucenter.dao.model.ItcsStationInfo;
import com.itcncp.ucenter.dao.model.ItcsStationInfoExample;
import com.itcncp.ucenter.rpc.api.ItcsStationInfoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
* ItcsStationInfoService实现
* Created by itcncp on 2018/1/12.
*/
@Service
@Transactional
@BaseService
public class ItcsStationInfoServiceImpl extends BaseServiceImpl<ItcsStationInfoMapper, ItcsStationInfo, ItcsStationInfoExample>
        implements ItcsStationInfoService {

    private static final Logger LOGGER = LoggerFactory.getLogger(ItcsStationInfoServiceImpl.class);

    @Autowired
    ItcsStationInfoMapper itcsStationInfoDao;

    /**
     * 查询收费站信息 根据天小时为档位进行缓存并缓存
     * @param  datehours
     * @return
     * - BaseServiceImpl方法根据读写操作自动切换主从数据源，继承的扩展接口，可手动通过`DynamicDataSource.setDataSource(DataSourceEnum.XXX.getName())`指定数据源
     */
    @Override
    @Cacheable(value = "itcncp-ucenter-rpc-service-ehcache", key = "'selectOwnerPlaza_' + #datehours")
    public List<ItcsStationInfo> selectOwnerPlazaByCache(String datehours) {
        return itcsStationInfoDao.selectByExample( new ItcsStationInfoExample() );
    }
}